import * as actionType from "./constance";

import { getSinger, getArtistList } from "@/services/artist";

const singer = (res) => ({
  type: actionType.GEISINGER,
  singers: res,
});

const artistList = (res) => ({
  type: actionType.GETARTISTLIST,
  artistLists: res,
});

export const singerAction = () => {
  return (dispatch) => {
    getSinger().then((res) => {
      dispatch(singer(res));
    });
  };
};
export const changeCurrentAreaAction = (area) => ({
  type: actionType.CHANGE_CURRENT_AREA,
  currentArea: area,
});

export const changeCurrentTypeAction = (type) => ({
  type: actionType.CHANGE_CURRENT_TYPE,
  currentType: type,
});

export const artistListAction = (limit, offset, type, area, initial) => {
  return (dispatch) => {
    getArtistList(limit, offset, type, area, initial).then((res) => {
      dispatch(artistList(res));
    });
  };
};
